﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QuickStart
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		internal MainPresenter Presenter { get; set; }

		public void AddTasks(IEnumerable<string> names)
		{
			var prototype = lblTasks;
			var top = prototype.Top + prototype.Height * 2;

			foreach (var name in names)
			{
				var task = new Button
				{
					Name = name,
					Text = name,
					Top = top,
					Left = prototype.Left, 
					Width = prototype.Width,
					Height = prototype.Height, 
				};
				task.Click += (sender, args) => ExecuteTask(((Button)sender).Name);

				this.Controls.Add(task);
				top += prototype.Height * 2;
			}
		}

		private void ExecuteTask(string name)
		{
			Presenter.Execute(name);
		}
	}
}